public class MTGenerator extends PackageGenerator {

	private static MTGenerator instance = null;
	public static MersenneTwister mt = null;

	private MTGenerator() {
		// Exists only to defeat instantiation.
	}

	public static MTGenerator getInstance() {
		if (instance == null) {
			mt = new MersenneTwister();
			instance = new MTGenerator();
		}
		return instance;
	}

	@Override
	public Package getPackage(int src) {
		
		int srcNode=src;
		int dstNode=Math.abs(mt.nextShort() % DataStore.getInstance().getNumberOfNodes());
		int flitSize=Math.abs(mt.nextInt()% DataStore.getInstance().getMaxFlitSize())+1;
		//System.out.println("Am facut un pachet: "+srcNode+" "+dstNode+" "+flitSize);
		return new Package(DataStore.getInstance().getNode(srcNode), DataStore.getInstance().getNode(dstNode),flitSize);
	}
}